package major;
import test.Common;

import java.util.ArrayList;
import java.util.List;

class Student extends Common {

    public Student(int id, int age, String name, String gender) {
        super();
        this.id = id;
        this.age = age;
        this.name = name;
        this.gender = gender;
    }

}

class Teacher extends Common{

    public Teacher(int id, int age, String name, String gender) {
        super();
        this.id = id;
        this.age = age;
        this.name = name;
        this.gender = gender;

    }
}


class Course extends Common{
//    与学生类和老师类不同的地方
    String place;
    String time;
    public  Course(int id, String name, String place, String time) {
        this.id = id;
        this.name = name;
        this.place = place;
        this.time = time;

    }

    @Override
    public String toString() {
        return "Course{" +
                "place='" + place + '\'' +
                ", time='" + time + '\'' +
                '}';
    }

    public String getPlace() {
        return place;
    }

    public String getTime() {
        return time;
    }
}

public class principal {
    public static void main(String[] args) {
//        new arrayList<泛型> 必须是引用类型
//        Integer 包装类
//        ArrayList底层基于数组实现
        List<Student> s1 = new ArrayList<>();
        List<Teacher> t1 = new ArrayList<>();
        List<Course> c1 = new ArrayList<>();
//        arrayList.get();
//        arrayList.add(Student student1 =  new Student(101,19,"小明","男"));
//        arrayList.set(1,"")修改元素

        Student student1 = new Student(101, 19, "小明", "男");
        Student student2 = new Student(102, 20, "小红", "女");
        Teacher teacher1 = new Teacher(001, 38, "王老师", "女");
        Teacher teacher2 = new Teacher(002, 35, "张老师", "男");
        Course course1 = new Course(1101, "Java", "综合教学楼103", "星期四上午十点");
        Course course2 = new Course(1102, "Python", "综合教学楼203", "星期二早上八点");

        s1.add(student1);
        s1.add(student2);
        t1.add(teacher1);
        t1.add(teacher2);
        c1.add(course1);
        c1.add(course2);


//        取出对象，拿到返回值
        for (int i = 0; i < 2; i++) {
            Student student = s1.get(i);
            Teacher teacher = t1.get(i);
            Course course = c1.get(i);
//      get 获得成员属性值
            System.out.println("------------");
            System.out.println("学生"+student.getName()+"选择了"+teacher.name+"的"+course.getName()+"课程\n"+

                            "上课地点是:"+course.getPlace()
                            + "上课时间是:"+course.getTime()
                    );
        }

    }
}